/**
*@author zhongrd
*@file 第三方平台配置管理
*@date 2019/5/20 16:42
*/
<template>
  <div style="background-color: #ececec; padding: 20px;height: 100%">
    <div class="thirdPlatform-card-div" v-for="item in cardData">
        <ta-card class="thirdPlatform-card" style="" title="平台名称:item.type">

            <a href="#" slot="extra">
              <ta-row :gutter="16">
                <ta-col :span="8">
                  <ta-icon type="edit" @click="fnEdit(item)"/>
                </ta-col>
                <ta-col :span="8">
                  <ta-popconfirm title="Are you sure delete this task?" @confirm="confirm(item)" @cancel="cancel" okText="Yes" cancelText="No">
                    <ta-icon type="delete" />
                  </ta-popconfirm>
                </ta-col>
              </ta-row>
            </a>
          <template v-for="item1 in item.list">
            <p><span>{{item1.name}}</span>:<span>{{item1.value}}</span></p>
          </template>
        </ta-card>
    </div>
    <div class="add-btn">
      <ta-button type="primary" shape="circle" icon="search" @click="showDrawer"></ta-button>
    </div>
    <ta-drawer
      title="新增和编辑"
      placement="right"
      :closable="false"
      @close="onClose"
      :visible="visible"
      width="1000"
    >
      <add :cardData="oneCard"></add>
    </ta-drawer>
  </div>
</template>

<script>
  import add from './part/add'

  let name = '张三'
  export default {
    name: 'manage',
    components: {add},
    data() {
      return {
        visible: false,
        cardData: [],
        oneCard:[],
      }
    },
    mounted(){
      this.fnQueryCard();
    },
    methods: {
      showDrawer() {
        this.oneCard=[]
        this.visible = true
      },
      onClose() {
        this.visible = false
      },
      fnQueryCard() {
          let submitParameter={
            url:"msg/thirdPlatform/thirdPlatformController/query.do"
          }
          let _this = this;
          Base.submit(_this,submitParameter,{
            successCallback:(data)=>{
              if (data.errors === null) {
                this.cardData = data.data.msgThirdPlatform
                console.log(this.cardData)
              } else {
                for (let i = 0; i < data.errors.length; i++) {
                  _source.$message.error(data.errors[i].msg)
                }
              }
            }
          })
      },
      fnEdit(data){
        this.oneCard=data;
        this.visible = true
      },
      fnDelete(data){
        let ids = [];
        let list = data.list;
        list.forEach(item=>{
          ids.push(item.id)
        });
        console.log(ids.join(","))
        let submitParameter={
          url:"msg/thirdPlatform/thirdPlatformController/delete.do",
          data:{"id":ids.join(",")}
        }
        let _this=this;
        Base.submit(_this,submitParameter,{
          successCallback:(data)=>{
            if (data.errors === null) {
              this.$message.success('已删除');
              this.fnQueryCard();
            } else {
              for (let i = 0; i < data.errors.length; i++) {
                _this.$message.error(data.errors[i].msg)
              }
            }
          }
        })
      },
      confirm(data){
        this.fnDelete(data);
      },
      cancel(e){

        this.$message.success('已取消')
      }
    },
  }
</script>

<style scoped type="text/scss">
  .thirdPlatform-card-div{
    display: inline-block;
  }
  .thirdPlatform-card{
    width: 300px;
    height:400px;
    overflow: hidden;
    margin-left: 20px;
  }
  .add-btn{
    display: inline-block;
  }
</style>
